#ifndef _HTTPAUTHENTICATIONPARAMS_HPP_
#define _HTTPAUTHENTICATIONPARAMS_HPP_

#include "jhdefs.hpp"
#include "net/NameValueCollection.hpp"
#include <string>

NET_NAMESPACE_BEGIN

class CHTTPRequest;
class CHTTPResponse;

class CHTTPAuthenticationParams : public CNameValueCollection
{
public:
	CHTTPAuthenticationParams();
	explicit CHTTPAuthenticationParams(const std::string& authInfo);
	explicit CHTTPAuthenticationParams(const CHTTPRequest& request);
	CHTTPAuthenticationParams(const CHTTPResponse& response, const std::string& header = WWW_AUTHENTICATE);
	virtual ~CHTTPAuthenticationParams();
	CHTTPAuthenticationParams& operator = (const CHTTPAuthenticationParams& authParams);

	void fromAuthInfo(const std::string& authInfo);
	void fromRequest(const CHTTPRequest& request);
	void fromResponse(const CHTTPResponse& response, const std::string& header = WWW_AUTHENTICATE);

	void setRealm(const std::string& realm);
	const std::string& getRealm() const;

	std::string toString() const;

	static const std::string REALM;
	static const std::string WWW_AUTHENTICATE;
	static const std::string PROXY_AUTHENTICATE;

private:
	void parse(std::string::const_iterator first, std::string::const_iterator last);
};

NET_NAMESPACE_END

#endif
